Kokyu (empresss residence) (後宮)
Kokyu palace was where the empress of the king or emperor lived.
In Japan, the Shichidengosha (a palace) located inside of Heian-kyo dairi (imperial palace of the ancient capital of Japan in current Kyoto) was an example of a Kokyu palace.
In general and through out history a kingdoms subjects maintained the concept that all men were barred from a 'Kokyu Palace'; yet, that image was not applied in all Japanese Kokyu palace situations. For example, a book written in the middle Heian period, "Genji Monogatari" (The Tale of Genji), illustrated the presence of male family members and close male acquaintances (nobles, aristocrats) frequently visiting ladies of the court in Kokyu palace. However, the O-oku (the inner halls of Edo Castle where the wife of the Shogun and her servants reside) of Edo castle was completely closed to all men and, except in case of an emergency, such as fire, male visitors were extremely limited.
Still, the Kokyu palaces in the Islamic dynasties such as Ottoman Empire and Chinese dynasties were forbidden to men's admittance. The castrated eunuches managed a general household affaires. In contrast, the court ladies, also called Kyujin, were developed to maintain the internal order of the Kokyu palaces instead of the castrated eunuches in Japan. It is well known that during the Heian period high ranking court ladies, called nyobo (court ladies), created an excellent form of court literature (for example, "Genji Monogatari" [The Tale of Genji]).
Additionally, the harem signified the Kokyu palace is based upon the Ottoman Empire which Kokyu palace was called harem.
Kokyu palaces in China
The Kokyu palaces of the Imperial court in China functioned as a place to have a domestic life for the emperor, and to live for his empress and the hihin (princess, noble's concubine, and court ladies) in the shared living environment. Therefore, in some case, the Empress herself to be called Kokyu. Additionally, most court ladies and the attending eunuchs lived in Kokyu palaces and engaged in the routine work duties of a Kokyu palace.
Under the Tang Dynasty system, rankings and service titles in a Kokyu palace were organized into three departments: Naikan, Kyukan, and Naishi Sho. Naikan means a princess and a mistress. There were four sub-ranks within this rank: First, there were four wives (four ladies who were the consorts of the emperor) (Guifei [貴妃], Shufei [淑妃], Defei [德妃], and Xianfei [賢妃]: First grade ranking). Second, there were nine mistresses (Zhaoyi [昭儀], Zhaorong [昭容], Zhaoyuan [昭媛], Xiuyi [修儀], Xiurong [修容], Xiuyuan [修媛], Chongyi [充儀], Chongrong [充容], and Chongyuan [充媛]: Second grade ranking). Third, there were twenty-seven seihu (a court lady) (nine Jieyus [婕妤], nine Beautiful Ladies [美人], and nine Talented Ladies [才人]: Third to fifth grade ranking). Fourth, there were eighty-one mime (the wife of a person holding high status) (27 Baolin [保林], 27 Imperial Woman [御女], and 29 Cainus [采女]: Sixth to eighth grade ranking). Lower than a sixth grade ranking were the Kyukan, who were the court ladies engaged in job duties at Kokyu palace. The Kyukan was further divided into six job titles (六尚, "liu-shang" in Chinese) and the pursuant job duties: Shang-kung (尚宮, Services related to General affairs), Shangyi (尚儀, Services related to Manner & Etiquette and Music), Shang-fu (尚服, Services related to Clothing), Shang-shih (尚食, Services related to Foods and Beverages), Shang-chin (尚寝, Services related to Housing and Living) and Shang-kung (尚功, Services related to Arts and Crafts). Additionally, a kung-cheng (宮正) position was established to regulate against injustices inside the Kokyu palace.
Then, a Naishi Sho (内侍省) was occupied by the eunuches.
Kokyu palaces in Korea
According to "Keikoku Taiten" ("Gyeongguk daejeon" in Korean, a Complete Code of Laws), naikan in the Yi Dynasty of Korea was organized in the following way: Pin (嬪, a first grade ranking), Kui-in (貴人, the associated first grade ranking), Soi (昭儀, a second grade ranking), Sugi (淑儀, the associated second grade ranking), Soyon (昭容, a third grade ranking), Sugyon (淑容, the associated third grade ranking), Sowon (昭媛, a forth grade ranking) and Suguon (淑媛, the associated forth grade ranking). From the first grade ranking through the associate fourth ranking, those ladies were referred to as a Kokyu for a King. Lower than fifth grade ranking ladies such as Sangun (尚宮) were court ladies who were engaged in duties of work at the Kokyu palaces.
Kokyu palaces in Japan
In Japan, the 'Gokuu kaninryo' (regulation codes for Kokyo palace; later, Yoro ritsuryo code [code promulgated in the Yoro period) changed this regulation code into 'Gokuu shikiinryo.') was established by the Taiho Ritsuryo (Taiho Code). Then, the Gokuu kaninryo created job titles for the kokyu junishi (twelve offices belonging to the Kokyu, empress's residence) and established Shichidengosha as the Kokyu palace of the Imperial court.
Defined terms by the Ritsuryo codes:
An empress
Hi (also pronounced, Kissak; a princess, or a consort): Restricted to no more than two ladies; a lady for this position should be a naishinno (imperial or royal princess) who was a fourth or higher grade in court raking. Fujin (also pronounced, Ootoji; consort of the emperor): restricted to no more than three ladies; a lady in this position should be the daughter of a Kugyo (high court noble) who held the position of Sanmi (a third court rank) or higher court ranking. Hin (also pronounced, Mime; a mistress): No more than four ladies; and a lady in this position should be the daughter of noble who was a Gomi (a fifth court rank) or higher court ranking.
Names used after the Heian Period:
Chugu: Originally a chugu referred to another name for an empress. In case there were several empresses later, a chugu mostly referred to all empresses chosen from the second wife downward. Additionally, when a Daijo-Tenno (the abdicated Emperor) had an empress after he abdicated, the empress was given the name of chugu.
Nyogo: Originally a nyogo referred to another name for Hin (a mistress) but this term evolved into a position of one in pursuit of the rank of an empress and chugu; therefore, a lady who planed to become an empress or a chugu became a nyogo first, according to custom.
Koi (nyokan [court lady]): Originally, a koi was a court lady who served at the 'benden' (emperor's temporary place of sojourn [a temporary stay]) but later the koi served in the emperor's bed room and was elevated into the position of consort next to the nyogo. A koi position was limited to twelve ladies; this was the custom in the period of nyokan.
Miyasudokoro: Originally, a miyasudokoro was a nyokan in service of the emperor's bedchamber (bedroom) but changed the meaning later to a miyasudokoro who served at emperor's bedroom and elevated to the position of a consort next to koi. Later, a miyasudokoro changed the meaning and referred to the nyokan who received an emperor's favor, and a consort of a Prince or Imperial Prince.
Mikushigedono: Originally a nyokan served at the 'Mikushirodono' (a place to prepare the wardrobe of an emperor) but changed the meaning later to a mikushigedono who served in the emperor's bedroom and was elevated to the position of a consort next to koi. The highest rank of mikushigedono was called 'betto' and in some cases, a lady who planed to become a nyogo worked as a mikushigedono betto first.
Nishinokami: Please refer to the section of Naishi no tsukasa (female palace attendants).